{% extends "teaBase.html" %}

{% block content %}
<div class="container-fluid text-left mb-3">
    <div class="container pt-3">
        <h3 class="mb-1">{{exam.name}}</h3>
        <!-- 这里给出老师正在判第几分卷子的第几题，y是一共要判的卷子数目以及当前卷子要判的题目数 -->
        <h5>第{{wa.work_finished}}/{{wa.work_count}}份试卷</h5>
    </div>
</div>

<div class="container w-75 exam-look-div">

    <span class="hidden-info" style="visibility:hidden">学生ID|答卷ID|题目ID</span>

    <div class="container mt-1">
        <h4 class="text-primary">问题：</h4>
        <p class="h5">{{questions.ctx}}</p>
        <hr>
    </div>

    <div class="container">
        <h4 class="text-danger">参考答案：</h4>
        <p class="h5">{{questions.correct_ans}}</p>
        <hr>
    </div>

    <div class="container">
        <h4 class="text-dark">考生答案：</h4>
        <p class="h5">{{stu_anss.ans}}</p>
        <hr>
    </div>

    <div class="mb-3 score-div">
        <label for="score">得分</label>
        <input type="text" id="score" value="">
        {%if wa.work_finished==wa.work_count%}
        <a href={{url_for('tea.teaIndex')}} class="btn btn-primary btn-sm" onclick="submitScore()">回到主界面</a>
        {%else%}
        <a href={{url_for('tea.judgeExam',exam_id=exam.id)}} class="btn btn-primary btn-sm" onclick="submitScore()">下一个</a>
        {%endif%}
    </div>

</div>

<script>
    function submitScore() {
        console.log(1);
        var testInfo = document.getElementsByClassName("hidden-info")[0];
        var paperId = testInfo.innerHTML.split("|")[0];
        var testId = testInfo.innerHTML.split("|")[1];
        var score = document.getElementById("score").value;
        var myForm = document.createElement("form");
        myForm.method = "post";
        var myInput1 = document.createElement("input");
        myInput1.setAttribute("name", "paperId");
        myInput1.setAttribute("value", paperId);
        myForm.appendChild(myInput1);
        var myInput2 = document.createElement("input");
        myInput2.setAttribute("name", "problemId");
        myInput2.setAttribute("value", testId);
        myForm.appendChild(myInput2);
        var myInput3 = document.createElement("input");
        myInput3.setAttribute("name", "score");
        myInput3.setAttribute("value", score);
        myForm.appendChild(myInput3);
        document.body.appendChild(myForm);
        myForm.submit();
        document.body.removeChild(myForm);
    }
</script>
{% endblock %}